#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using std::cin;
using std::cout;
using std::vector;

template<typename Iter, typename Comp>
Iter Max_to_end(Iter begin, Iter end, Comp cmp) {
	if (begin == end) {
		return end;
	}
	Iter max_position = std::max_element(begin, end, cmp);
	--end;
	std::swap(*max_position, *end);
	return end;
}


template<typename T>
void Input(std::istream &input, vector<T> &sequence) {
	size_t size;
	input >> size;
	sequence.resize(size);
	for (size_t index = 0; index < size; ++index) {
		input >> sequence[index];
	}
}

template<typename T>
void Output(std::ostream &output, vector<T> &sequence) {
	for (size_t index = 0; index < sequence.size(); ++index) {
		output << sequence[index] << " ";
	}
}

int main() {
	vector<int> sequence;
	Input(cin, sequence);
	Max_to_end(sequence.begin(), sequence.end(), std::less<int>());
	Output(cout, sequence);
}

